package com.liugan.magic.active;

import org.loon.framework.android.game.LGameAndroid2DActivity;
import org.loon.framework.android.game.core.LSystem;
import org.loon.framework.android.game.core.graphics.opengl.LTexture;
import org.loon.framework.android.game.core.graphics.opengl.LTexture.Format;

import android.util.Log;
import android.widget.Toast;

import com.liugan.magic.Constants;
import com.liugan.magic.screen.GameScreen;
import com.liugan.magic.sound.ASound;

import dalvik.system.VMRuntime;

public class GameMain extends LGameAndroid2DActivity {
	GameScreen gs=null;
	
	private final static int CWJ_HEAP_SIZE = 55*1024*1024 ;
	private final static float TARGET_HEAP_UTILIZATION = 0.75f;
	public void onMain() {
		//VMRuntime.getRuntime().setMinimumHeapSize(CWJ_HEAP_SIZE);
		//VMRuntime.getRuntime().setTargetHeapUtilization(TARGET_HEAP_UTILIZATION); 
		LTexture lt=new LTexture("assets/logo.png", Format.STATIC);
		//Constants.ScreenWIDTH=480;
		//Constants.ScreenHEIGHT=320;
		
		this.maxScreen(Constants.ScreenWIDTH,Constants.ScreenHEIGHT);
		this.initialization(true);
		this.setLogo(lt);
		this.setShowLogo(true);
		this.setShowMemory(true);
		this.setShowFPS(true);
		this.setScreen(gs=new GameScreen());
		Toast.makeText(this,Constants.nocomplete,Toast.LENGTH_SHORT).show();
		this.showScreen();
		this.setFPS(40);
		LSystem.gc();
	}

	@Override
	public void onGamePaused() {
		ASound.getInstance().quiet();
		//Log.i("aaa", "onGamePaused");
	}

	@Override
	public void onGameResumed() {
		if ((gs!=null)&&(gs.getGlayer()!=null)&&(gs.getGlayer().isIssound())){
			ASound.getInstance().voice();
		}
		//Log.i("aaa", "onGameResumed");
	}

}